package com.xindz.hgq.main;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Button;
import android.widget.TextView;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.SPUtils;
import com.xindz.hgq.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bingoogolapple.bgabanner.BGABanner;

/**
 * @name HGQBase
 * @class name：com.xindz.hgq.app
 * @describe 引导页应用第一次今日时显示
 * @anthor XINDZ
 * @time 2018/1/2 11:59
 * @change
 * @chang time
 * @class describe
 */
public class GuideActivity extends Activity {

    @BindView(R.id.banner_guide_bcakgorund)
    BGABanner bannerGuideBcakgorund;
    @BindView(R.id.banner_guide_foreground)
    BGABanner bannerGuideForeground;
    @BindView(R.id.tv_guide_skip)
    TextView tvGuideSkip;
    @BindView(R.id.bt_guide_enter)
    Button btGuideEnter;
    private Unbinder bind;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actvity_guide);
        bind = ButterKnife.bind(this);
        initListener();
        bannerGuideBcakgorund.setData(R.drawable.uoko_guide_background_1,R.drawable.uoko_guide_background_2,R.drawable.uoko_guide_background_3);
        bannerGuideForeground.setData(R.drawable.uoko_guide_foreground_1,R.drawable.uoko_guide_foreground_2,R.drawable.uoko_guide_foreground_3);
    }

    @Override
    protected void onResume() {
        super.onResume();
        bannerGuideBcakgorund.setBackgroundResource(android.R.color.white);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        bind.unbind();
    }
    private void initListener() {
        /**
         * 设置进入按钮和跳过按钮控件资源 id 及其点击事件
         * 如果进入按钮和跳过按钮有一个不存在的话就传 0
         * 在 BGABanner 里已经帮开发者处理了防止重复点击事件
         * 在 BGABanner 里已经帮开发者处理了「跳过按钮」和「进入按钮」的显示与隐藏
         */
        bannerGuideForeground.setEnterSkipViewIdAndDelegate(R.id.bt_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
            @Override
            public void onClickEnterOrSkip() {
                SPUtils.getInstance().put("Guide",false);
                ActivityUtils.startActivity(MainActivity.class);
                finish();
            }
        });
    }
}
